
<link href="<?php echo Yii::app()->request->baseUrl; ?>/css/all.css" rel="stylesheet" type="text/css" />
<link href="<?php echo Yii::app()->request->baseUrl; ?>/css/supersized.css" rel="stylesheet" type="text/css" />

<!--[if IE 7]>
	<link href="css/ie.css" rel="stylesheet" type="text/css" />
<![endif]-->

<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/supersized.3.1.3.core.js"></script>
<script type="text/javascript">  
			jQuery(function($){
				$.supersized({
					//Background image
					slides	:  [ { image : '<?php echo Yii::app()->request->baseUrl; ?>/images/bg.jpg' } ]					
				});
			});
</script>


<link href="<?php echo Yii::app()->request->baseUrl; ?>/css/select2.css" rel="stylesheet" type="text/css" /><!-- select2.css for Support Page -->
<script language="JavaScript" type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery.dd.js"></script>
<script language="javascript" type="text/javascript">
function showvalue(arg) {
	alert(arg);
	//arg.visible(false);
}

$(document).ready(function() {

try {
		//$("body select").msDropDown();
	//	$("#segment").msDropDown({useSprite:'sprite'})
		//TODO: figure out what's going on here?'
	//	$("<?php echo "#".get_class($org_model)."_organization_type_ID"?>").msDropDown({useSprite:'sprite'})
	//	$("#ver").html($.msDropDown.version);
		} catch(e) {
			alert("Error: "+e.message);
		}
})
</script>
<script type="text/javascript">

function updateFields(data)
{
	
	var prefix='<?php echo get_class($org_model)?>';
	var suffix=new Array("_DBA", "_fed_ID", "_address1", "_city", "_state", "_zip", "_organization_type_ID");
	for(var i=0;i<suffix.length;i++)
	{
		if(i<data.length-1)
		{
			var element=document.getElementById(prefix+suffix[i]);
			if(i==data.length-2)
			{
				for(var j=0;j<element.options.length;j++)
				{
					if(element.options[j].value==data[i])
						element.selectedIndex=j;
				}
			}
			else
			{
				element.value=data[i];
			}
			element.disabled=true;
		}
		else
		{
			var element=document.getElementById(prefix+suffix[i]);
			element.disabled=false;
		}
	}
	
	var checkBoxes=document.getElementsByName('organization_products[]');
	if(suffix.length>data.length)//not a existing organization, enable the checkboxes
	{
		for(i=0;i<checkBoxes.length;i++)
		{
			checkBoxes[i].checked=false;
			checkBoxes[i].disabled=true;
		}
	}
	else
	{
		for(i=0;i<checkBoxes.length;i++)
		{
			for(j=0;j<data[data.length-1].length;j++)
			{
				if(checkBoxes[i].value==data[data.length-1][j])
					checkBoxes[i].checked=true;
			}
			checkBoxes[i].disabled=true;
		}
	}

}

function enableElements()
{
	var prefix='<?php echo get_class($org_model)?>';
	var suffix=new Array("_DBA", "_fed_ID", "_address1", "_city", "_state", "_zip", "_organization_type_ID");
	for(var i=0;i<suffix.length;i++)
	{
		var element=document.getElementById(prefix+suffix[i]);
		element.disabled=false;
	}
}
</script>
<script>
function updateErrInfo(data)
{
	var element=document.getElementById('<?php echo get_class($model)."_user_name_em_";?>');
	element.innerHTML=data;
	element.style.display='block';
}
</script>

<?php $this->pageTitle='ekos AUCTIONS' ?>

<?php $form = $this->beginWidget('CActiveForm', array(
		'id'=>'register-form',
		'enableClientValidation'=>true,
		));
?>

<div align='right' style='color:#FF0000'>
<?php echo $form->error($org_model, 'organization_name'); ?>
<?php echo $form->error($org_model, 'DBA'); ?>
<?php echo $form->error($org_model, 'address1'); ?>
<?php echo $form->error($org_model, 'city'); ?>
<?php echo $form->error($org_model, 'state'); ?>
<?php echo $form->error($org_model, 'zip'); ?>
<?php echo $form->error($org_model, 'fed_ID'); ?>
<?php echo $form->error($model, 'contact_first_name'); ?>
<?php echo $form->error($model, 'contact_last_name'); ?>
<?php echo $form->error($model, 'phoneNumber'); ?>
<?php echo $form->error($model, 'emailAddress'); ?>
<?php echo $form->error($model, 'user_name'); ?>
<?php echo $form->error($model, 'password'); ?>
<?php echo $form->error($model, 'password2'); ?>
</div>
<div id="content-wrapper3">
<h1 id="logo"><a href="#">Ekos Auctions</a></h1>
<div id="tagline">&#275;kos finds the <span>perfect suppliers</span> for you!</div>
<div id="registration">
<div id="reg-contents">

<div id="rstep1">
<div id="rstep1-contents">
<div id="rstep1-head">Step 1...</div>

<div id="rstep1-ch">Tell Me About Yourself</div>

<div id="rstep1-form1">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th width="125"><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/full-legal-name.gif" alt="" width="90" height="10" /></th>
    <td width="560">
    	<div class="rstep1-box1">
    		<?php 
				$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
					'model'=>$org_model,
					'attribute'=>'organization_name',
					'value'=>'',
					'source'=>CController::createUrl('registration/autocompleteOrg'),
					'options'=>array(
								'showAnim'=>'fold',
								'minLength'=>3,
								//	'select' => "js:function(event, ui) { $('#".get_class($model)."_organization_ID').val(ui.item.id);}",
									),
					'htmlOptions'=>array(
									'ajax'=>array( 
											'type'=>'POST',
											'url'=>CController::createUrl('registration/orginfo'),
											'success'=>'updateFields',
											'dataType'=>'json',
										),
									)
				));
			?>
    	</div>
    </td>
  </tr>
  <tr>
    <th width="125"><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/dba.gif" alt="" width="80" height="12" /></th>
    <td>
    	<div class="rstep1-box1">
    		<?php echo $form->textField($org_model, 'DBA'); ?>
    	</div>
    </td>
  </tr>
  <tr>
    <th width="125"><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/billing-address.gif" alt="" width="87" height="10" /></th>
    <td>
    	<div class="rstep1-box1">
    		<?php echo $form->textField($org_model, 'address1'); ?>
    	</div>
    </td>
  </tr>
  <tr>
    <td colspan="2">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <th width="125"><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/city2.gif" alt="" width="22" height="10" /></th>
          <td width="209">
          	<div class="rstep1-box2">
				<?php echo $form->textField($org_model, 'city'); ?>
          	</div>
          </td>
          <th width="38"><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/state2.gif" alt="" width="29" height="10" /></th>
          <td>
          	<div class="rstep1-box4">
		  		<?php echo $form->textField($org_model, 'state', array('size'=>2)); ?>
		  	</div>
		  </td>
          <th width="25"><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/zip2.gif" alt="" width="16" height="10" /></th>
          <td>
          	<div class="rstep1-box4">
          		<?php echo $form->textField($org_model, 'zip'); ?>
          	</div>
          </td>
        </tr>
      </table>    </td>
    </tr>
  <tr>
    <th width="125"><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/fedid.gif" alt="" width="42" height="10" /></th>
    <td>
    	<div class="rstep1-box5">
    		<?php echo $form->textField($org_model, 'fed_ID'); ?>
    		<input type='input'/>
    	</div>
    </td>
  </tr>
</table>
</div><!-- End Step1 form1 -->

<div id="rstep1-form2">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/organization-type.gif" alt="" width="101" height="10" /></th>
    <td><div class="rstep1-box6">
   		<?php echo $form->dropDownList($org_model, 'organization_type_ID', 
							OrganizationTypes::model()->loadOrgTypes(),
							array('style'=>"width:282px;")
							); ?>
    </div></td>
  </tr>
  <tr>
    <th><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/first-name.gif" alt=""/></th>
    <td>
    	<div class="rstep1-box5">
    		<?php echo $form->textField($model, 'contact_first_name'); ?>
    	</div>
    </td>
  </tr>
    <tr>
    <th><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/lastname.gif" alt=""/></th>
    <td>
    	<div class="rstep1-box5">
    		<?php echo $form->textField($model, 'contact_last_name'); ?>
    	</div>
    </td>
  </tr>
  <tr>
    <th><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/phone.gif" alt="" width="34" height="10" /></th>
    <td>
    	<div class="rstep1-box5">
    		<?php echo $form->textField($model, 'phoneNumber'); ?>
    	</div>
    </td>
  </tr>
  <tr>
    <th><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/email-address.gif" alt="" width="79" height="11" /></th>
    <td>
    	<div class="rstep1-box5">
			<?php echo $form->textField($model, 'emailAddress'); ?>
    	</div>
    </td>
  </tr>
</table>
</div><!-- End Step1 form2 -->
</div><!-- End Step1 Contents -->
</div>
<!-- End Step1 -->

<div id="rstep2">
<div id="rstep2-contents">
<div id="rstep2-head">Step 2...</div>
<div id="rstep2-ch"><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/spacer.gif" alt="" /></div>

<div id="rstep2-form">
    <div class="rstep2-name"><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/create-username.gif" alt="" /></div>
    <div class="rstep2-box">
    	<?php echo $form->textField($model, 'user_name', array(
									'ajax'=>array( 
											'type'=>'POST',
											'url'=>CController::createUrl('registration/checkvalid'),
											'success'=>"updateErrInfo",
										),
									)); ?>
    </div>
    <div class="rstep2-name"><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/create-password.gif" alt="" /></div>
    <div class="rstep2-box">
    	<?php echo $form->passwordField($model, 'password'); ?>
    </div>
    <div class="rstep2-name"><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/retype-pass.gif" alt="" /></div>
    <div class="rstep2-box">
    	<?php echo $form->passwordField($model, 'password2'); ?>
    </div>
    <div class="rstep2-note">Must be at least 6 characters or numbers</div>
</div><!-- End Step2 Form -->
</div><!-- End Step2 Contents -->
</div>
<!-- End Step2 -->
<?php
function printProducts()
{
	$typeArray=Products::model()->getProductTypes();
	$counter=0;
	foreach($typeArray as $type)
	{
		echo "<h1>$type</h1>";
		echo "<ul>";
		$namesArray=Products::model()->getProductNames($type);

		foreach($namesArray as $name)
		{
			echo "<li><input name='organization_products[]' type='checkbox' value='".$name['value']."' />".$name['display']."</li>";
			$counter++;
		}
		echo "</ul>";
	}
}
?>
